This is the simple demonstration in JavaScript how to use confirmation box. Confirmation box are used for check the user confirmation for example you want to delete this item, you want to continue this page etc.
So, this is the simple code how to use confirmation box.
Write this code on aspx page
<headrunat="server">
<title>Sample for Confirmation Box</title>
<scripttype="text/javascript">
function FuncCheck() {
var strVal = confirm("Are you sure you want to show this content?");
if (strVal == true) {
returntrue;
}
else {
var lblMsg = document.getElementById('lblMsg');
lblMsg.innerHTML = "";
returnfalse;
}
}
</script>
</head>
<body>
<formid="form1"runat="server">
<div>
<asp:ButtonID="btnSubmit"runat="server"Text="Submit"OnClientClick="return FuncCheck()"
OnClick="btnSubmit_Click"/>
<asp:LabelID="lblMsg"runat="server"></asp:Label>
</div>
</form>
</body>
And write this code at code behind page
protectedvoid btnSubmit_Click(object sender, EventArgs e)
{
lblMsg.Text = "This is your content.....";
}
Leave Comment